﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BCDto.TMS.MallInterface
{
    /// <summary>
    /// 商品信息
    /// </summary>
    public class MallOrderGoodsDto
    {
        /// <summary>
        /// 商品名称 R
        /// </summary>
        public string GoodsName { get; set; }

        /// <summary>
        /// 商品编码SKU  O
        /// </summary>
        public string GoodsSKU { set; get; }

        /// <summary>
        /// 商品照片 O
        /// </summary>
        public string GoodsPhoto { set; get; }

        /// <summary>
        /// 商品单位 O
        /// </summary>
        public string GoodsUnit { set; get; }

        /// <summary>
        /// 商品数量  O
        /// </summary>
        public int GoodsQuantity { set; get; }

        /// <summary>
        /// 商品价格  O
        /// </summary>
        public decimal? GoodsPrice { set; get; }

        /// <summary>
        /// 商品重量  R
        /// </summary>
        public decimal GoodsWeight { set; get; }

        /// <summary>
        /// 商品体积  O
        /// </summary>
        public decimal? GoodsVolume { set; get; }

        /// <summary>
        /// 商品长-单位厘米(CM)  R
        /// </summary>
        public decimal GoodsLength { set; get; }

        /// <summary>
        /// 商品宽-单位厘米(CM) R
        /// </summary>
        public decimal GoodsWidth { set; get; }

        /// <summary>
        /// 商品高-单位厘米(CM) R
        /// </summary>
        public decimal GoodsHeight { set; get; }

        /// <summary>
        /// 商品描述  O
        /// </summary>
        public string GoodsDesc { set; get; }


        /// <summary>
        /// 获取长宽高最大值
        /// </summary>
        /// <returns></returns>
        public decimal GetLength()
        {
            decimal max = GoodsLength;
            if (GoodsWidth > max)
                max = GoodsWidth;
            if (GoodsHeight > max)
                max = GoodsHeight;
            return (decimal)max;
        }

        /// <summary>
        /// 获取长宽高中间值
        /// </summary>
        /// <returns></returns>
        public decimal GetWidth()
        {
            decimal maxAB = Math.Max(GoodsLength, GoodsWidth);
            decimal minAB = Math.Min(GoodsLength, GoodsWidth);

            return (decimal)(maxAB > GoodsHeight ? Math.Max(minAB, GoodsHeight) : maxAB);
        }

        /// <summary>
        /// 获取长宽高最小值
        /// </summary>
        /// <returns></returns>
        public decimal GetHight()
        {
            decimal min = GoodsLength;
            if (GoodsWidth < min)
                min = GoodsWidth;
            if (GoodsHeight < min)
                min = GoodsHeight;
            return (decimal)min;
        }
    }
}
